package com.wgts.wgts.tools;

import android.content.Context;
import android.support.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.load.engine.cache.ExternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.stream.HttpGlideUrlLoader;
import com.bumptech.glide.module.AppGlideModule;
import com.wgts.wgts.netmodle.AppOkHttpClient;

import java.io.File;
import java.io.InputStream;
import java.lang.annotation.Annotation;

import okhttp3.OkHttpClient;

@GlideModule
public class QualityModule extends AppGlideModule {


    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        //修改默认配置，如缓存配置
        //设置磁盘缓存保存在外部存储，且指定缓存大小
        builder.setDiskCache(new ExternalPreferredCacheDiskCacheFactory(context, "MoHuPicCache", 40 * 1024 * 1024));
    }

    @Override
    public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
        //替换组件，如网络请求组件
        registry.replace(GlideUrl.class, InputStream.class, new HttpGlideUrlLoader.Factory());
    }


    @Override
    public boolean isManifestParsingEnabled() {
        return false;
    }





}
